<?php
/**
 * ============================================================================
 * Copyright (c) 2015-2018 贵州大师兄信息技术有限公司 All rights reserved.
 * siteַ: http://www.dsxcms.com
 * ============================================================================
 * @author:     David Song<songdewei@163.com>
 * @version:    v1.0.0
 * ---------------------------------------------
 * Date: 2018/8/29
 * Time: 下午12:05
 */

namespace App\WeChat\WxPay\Order;

//企业向个人付款
class WxPayTransferOrder extends WxPayOrder
{
    protected $values = [
        'mch_appid'=>null,
        'mchid'=>null,
        'nonce_str'=>null,
        'spbill_create_ip'=>null,
        'partner_trade_no'=>null,
        'check_name'=>'NO_CHECK',
        'amount'=>null,
        'desc'=>null,
        'openid'=>null,
        're_user_name'=>null
    ];

    /**
     * @param null $value
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function setMchAppid($value = null){
        if (is_null($value)) {
            $this->values['mch_appid'] = setting('wx_appid');
        }else {
            $this->values['mch_appid'] = $value;
        }
    }

    /**
     * @return mixed
     */
    public function getMchAppid(){
        return $this->values['mch_appid'];
    }

    /**
     * @param null $value
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function setMchid($value = null){
        if (is_null($value)) {
            $this->values['mchid'] = setting('wx_mch_id');
        }else {
            $this->values['mchid'] = $value;
        }
    }

    /**
     * @return mixed
     */
    public function getMchid(){
        return $this->values['mchid'];
    }

    /**
     * 设置随机字符串，不长于32位。推荐随机数生成算法
     * @param string $value
     **/
    public function setNonceStr($value = null)
    {
        if (is_null($value)) {
            $this->values['nonce_str'] = md5(time().rand(100,999));
        }else {
            $this->values['nonce_str'] = $value;
        }
    }

    /**
     * 获取随机字符串，不长于32位。推荐随机数生成算法的值
     * @return string 值
     **/
    public function getNonceStr()
    {
        return $this->values['nonce_str'];
    }

    /**
     * 设置调用微信支付API的机器IP
     * @param string $value
     **/
    public function setSpbillCreateIp($value = null)
    {
        if (is_null($value)) {
            $this->values['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
        }else {
            $this->values['spbill_create_ip'] = $value;
        }
    }

    /**
     * 获取调用微信支付API的机器IP 的值
     * @return string 值
     **/
    public function getSpbillCreateIp()
    {
        return $this->values['spbill_create_ip'];
    }

    /**
     * @param $value
     */
    public function setPartnerTradeNo($value){
        $this->values['partner_trade_no'] = $value;
    }

    /**
     * @return mixed
     */
    public function getPartnerTradeNo(){
        return $this->values['partner_trade_no'];
    }

    /**
     * @param string $value
     */
    public function setCheckName($value = 'NO_CHECK'){
        $this->values['check_name'] = $value;
    }

    /**
     * @return mixed
     */
    public function getCheckName(){
        return $this->values['check_name'];
    }

    /**
     * @param $value
     */
    public function setAmount($value){
        $this->values['amount'] = $value;
    }

    /**
     * @return mixed
     */
    public function getAmount(){
        return $this->values['amount'];
    }

    /**
     * @param $value
     */
    public function setDesc($value){
        $this->values['desc'] = $value;
    }

    /**
     * @return mixed
     */
    public function getDesc(){
        return $this->values['desc'];
    }

    /**
     * @param $value
     */
    public function setOpenid($value){
        $this->values['openid'] = $value;
    }

    /**
     * @return mixed
     */
    public function getOpenid(){
        return $this->values['openid'];
    }

    /**
     * @param $value
     */
    public function setReUserName($value){
        $this->values['re_user_name'] = $value;
    }

    /**
     * @return mixed
     */
    public function getReUserName(){
        return $this->values['re_user_name'];
    }
}
